#st段 趋势图
<template>
  <div id="STTrend">
    <div class="chartBox">
      <div class="left">
        <div v-for="(item, index) in hrList" :key="index" class="container">
          <span>{{ item.name }}</span>
          <div :id="&quot;heartRate&quot; + index" class="heartRate"></div>
        </div>
      </div>
      <div class="right">
        <ecg-chart 
          ref = "ecgChart"
          :width-value="ecgWidthValue" 
          :height-value="ecgHeightValue"
        ></ecg-chart>
      </div>
    </div>
    <div class="btnBox">

    </div>
  </div>
</template>

<script>
var Highcharts = require('highcharts')
import EcgChart from '@/components/ecgChart'

export default {
  components: {
    EcgChart
  },
  data() {
    return {
      ecgWidthValue: undefined,
      ecgHeightValue: undefined,
      data: [],
      hrList: [
        {
          name: 'I'
        }, {
          name: 'II'
        }, {
          name: 'III'
        }
      ]
    }
  },
  created() {
    this.data = require('./../../../../public/js/test.json')
    this.$nextTick(() => {
      this.ecgWidthValue = window.innerWidth - 10
      this.ecgHeightValue = document.querySelector('.chartBox').offsetHeight * 0.33
      for (let i = 0; i < 3; i++) {
        this.createHRChart(i)
      }
    })
  },
  methods: {
    createHRChart(index) {
      const data = this.data
      const heightValue = document.querySelector('.chartBox').offsetHeight * 0.33
      Highcharts.chart(`heartRate${index}`, {
        chart: {
          height: heightValue,
          reflow: false,
          borderWidth: 0,
          backgroundColor: '#FFF',
          zoomType: 'x'
        },
        title: {
          text: null
        },
        xAxis: {
          type: 'datetime',
          showLastTickLabel: true,
          maxZoom: 14 * 24 * 3600000, // fourteen days
          plotBands: [{
            id: 'mask-before',
            from: data[0][0],
            to: data[data.length - 1][0],
            color: '#FFF'
          }],
          title: {
            text: null
          }
        },
        yAxis: {
          gridLineWidth: 0,
          labels: {
            enabled: false
          },
          title: {
            text: null
          },
          min: 0.6,
          showFirstLabel: false
        },
        tooltip: {
          formatter: function() {
            return false
          }
        },
        legend: {
          enabled: false
        },
        credits: {
          enabled: false
        },
        plotOptions: {
          series: {
            lineWidth: 1,
            marker: {
              enabled: false
            },
            shadow: false,
            states: {
              hover: {
                lineWidth: 1
              }
            },
            enableMouseTracking: false
          }
        },

        series: [{
          type: 'area',
          name: 'USD to EUR',
          pointInterval: 24 * 3600 * 1000,
          pointStart: data[0][0],
          data: data
        }],

        exporting: {
          enabled: false
        }

      }, function(masterChart) {
      })
    }
  }
}
</script>

<style lang="scss" scoped>
#STTrend {
  width: 100%;
  height: 100%;
  
  .chartBox {
    width: 100%;
    height: calc(100% - 60px);
    display: flex;
    border: 1px solid seagreen;
    .left {
      width: 50%;
      .container {
        display: flex;
        align-items: center;
        span {
          width: 18px;
          padding: 0 10px;
        }
        .heartRate {
          width: 100%;
        }
      }
    }
    .right {
      width: 50%;
    }
  }
  .btnBox {
    width: 100%;
    height: 60px;
    border: 1px solid salmon;
  }
  .el-dialog {
    .leadList {
      display: flex;
      flex-wrap: wrap;
      .item {
        width: 53px;
        margin-top: 10px;
      }
    }
    .list {
      margin-top: 10px;
      .name {
        font-size: 14px;
        color: #4a4a4a;
        text-align: left;
        width: 100px;
        display: inline-block;
      }
      .el-select {
        width: 115px;
      }
    }
  }
}
</style>



